package net.adetech.crj.service;


import net.adetech.crj.dao.AppointmentMapper;
import net.adetech.crj.entity.Appointment;
import net.adetech.crj.utils.InnerServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@Service("appointment.getByIdNumber")
public class GetAppointmentByIdNumberService implements BaseService{
    @Autowired
    AppointmentMapper appointmentMapper;

    @Override
    public Map<String, Object> invoke(Map<String, Object> params) {
        String idNumber = (String)params.get("idNumber");
        String dayId = new SimpleDateFormat("yyyyMMdd").format(new Date());
        Appointment appointment = appointmentMapper.getAppointmentByIdNumber(idNumber,dayId);
        return InnerServiceUtil.buildResult("appointment",appointment);
    }
}
